<?php
include("../config/config.php");
include("include/function.php");
$sid=$_GET['i'];
if (empty($sid)){
    echo "Empty Share ID";
    exit;
}
$db_link=DB_Link();
$playfile="html/ck.tpl";
$out=file_get_contents($playfile);
$row_video=mysqli_fetch_array(mysqli_query($db_link,"SELECT * FROM video_list WHERE shareid = '".$sid."'"));
if (empty($row_video['ID'])){
    echo "Error Share ID-2";
    exit;
}
if ($row_video['status <> 2']) die('视频处理中，暂时无法观看');
$p['m3u8']="/".$row_video['day']."/".$row_video['random']."/index.m3u8";
$p['name']=name($row_video['filename']);
$p['mtime']=playtime($row_video['m_time']);
$p['msize']=size($row_video['m_size']);
$p['pic']=$row_video['day']."/".$row_video['random']."/1.jpg";
$p['redirecturl']='';
$p['token']="pm".$row_video['sid'];
$p['shareid']=$sid;
$p['refer']='';
foreach ($p as $k => $v){
    $r="[$k]";
    $out=str_replace($r,$v,$out);
}
echo $out;
exit;


function name($str){
  $i=strrpos($str,".");
  return substr($str,0,$i);
}

function playtime($d){
  return date("H:i:s",$d);
}
function size($s){
  $n=$s/1024/1024;
  return sprintf("%.2f", $n);
}
?>